package com.shxt.service;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import com.shxt.data.D_User_UploadMapper;
import com.shxt.pojo.D_User_Upload;


public class D_User_UploadService implements D_User_UploadMapper {
	
	private static D_User_UploadService instance = null;
	
	public static D_User_UploadService getInstance(){
		if(instance==null){
			instance = new D_User_UploadService();
		}
		return instance;
	}

	@Override
	public int addFile(D_User_Upload duu) {
		SqlSession session = MyFactory.sessionFactory().openSession();
		int i = 0;
		try{
			D_User_UploadMapper duum = session.getMapper(D_User_UploadMapper.class);
			duum.addFile(duu);
			session.commit();
			i=1;
		}finally{
			if(session!=null){
				session.close();
			}
		}
		return i;
	}

	@Override
	public List<D_User_Upload> folderFileData(long floderId) {
		List<D_User_Upload> lduu = null;
		SqlSession session = MyFactory.sessionFactory().openSession();
		try{
			D_User_UploadMapper duum = session.getMapper(D_User_UploadMapper.class);
			lduu = duum.folderFileData(floderId);
		}finally{
			if(session!=null){
				session.close();
			}
		}
		return lduu;
	}

	@Override
	public List<D_User_Upload> selectUserFolder(Map<String, String> mss) {
		List<D_User_Upload> lduu = null;
		SqlSession session = MyFactory.sessionFactory().openSession();
		try{
			D_User_UploadMapper duum = session.getMapper(D_User_UploadMapper.class);
			lduu = duum.selectUserFolder(mss);
		}finally{
			if(session!=null){
				session.close();
			}
		}
		return lduu;
	}
}
